import time

class Record:
    def __init__(self,zhi,name):
        self.zhi = str(zhi)
        self.name = name
        self.time = ''
    def __get__(self,instance,name):
        self.time = time.asctime(time.localtime())
        self.pt= '%s 变量与北京时间 %s 被读取,%s = %s\n' %(self.name,self.time,self.name,self.zhi)
        print(self.zhi)
        with open('record.txt','a') as f1:
            f1.write(self.pt)
            
    def __set__(self,instance,value):
        self.zhi = str(value)
        self.time = time.asctime(time.localtime())
        self.pt= '%s 变量与北京时间 %s 被修改,%s = %s\n' %(self.name,self.time,self.name,self.zhi)
        with open('record.txt','a') as f1:
            f1.writelines(self.pt)

class Test:
    x=Record(10,'x')
    y=Record(8.8,'y')
    


test=Test()
test.x
test.y
test.x=123
test.x=1.23
test.y='12'
